<template>
    <div>
      <ManegeHeader :tips="tips" :root="root" @isRoot="isRoot"></ManegeHeader>
      <router-view :root="root"></router-view> 
    </div>
  </template>
    
    <script>
  import ManegeHeader from "./ManegeHeader.vue";
  // 引入路由器
  import router from "../router";
  import axios from "axios";
  import VueCookies from "vue-cookies";
  
  export default {
    name: "App",
    router: router,
    components: {
      ManegeHeader,
    },
    methods: {
      isRoot: function () {
        
        // 判断是否为管理员
        axios({
          method: "POST",
          url: "http://localhost:8081/lo/intercept/goods/isroot",
          params: {
            uid: VueCookies.get("uid"),
            ucookie: VueCookies.get("ucookie"),
          },
          headers: {
            headers: {
              "Content-Type": "application/x-www-form-urlencoded",
            },
          },
        }).then(
          (response) => {
            // console.log("返回"+response.data);
            if (response.data == "0") {
              // 不是用户管理员
              // alert("该操作只能是管理员才能操作！！！");
            } else {
              this.root = 1;
              // console.log(this.root);
            }
            // console.log("更新的："+this.root);
          },
          (error) => {
            alert("请求失败,请检查服务器是否开启！");
          }
        );
      },
    },
    data() {
      return {
        root: 0, //默认不是管理员
        tips: [
          { tip: "用户管理", tipline: "User" },
          { tip: "商品管理", tipline: "Goods" },
          { tip: "订单管理", tipline: "Reservation" },
          { tip: "钱包管理", tipline: "Undeveloped" },
          { tip: "基础管理", tipline: "Undeveloped" },
        ],
      };
    },
  };
  </script>
    
    <style scoped>
  div {
    background-color: #565c64;
  }
  </style>
    